<?php
/*
 * Created on Oct 3, 2008
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
 
 include 'register.html';http://subclipse.tigris.org/update_1.4.xhttp://subclipse.tigris.org/update_1.4.x
 
$name = $_POST['name'];
$email = $_POST['email'];    
$username = $_POST['username'];
$password = md5($_POST['password']);

// lets check to see if the username already exists
$db = new dbLink ("antipants");
$checkuser = $db->query ("SELECT username FROM users WHERE username='$username'");
$username_exist = mysql_num_rows($checkuser);

if($username_exist > 0)
{
	echo "I'm sorry but the username you specified has already been taken.  Please pick another one.";
	unset($username);
}

// lf no errors present with the username
// use a query to insert the data into the database.

$query = $db->query ("INSERT INTO users (name, email, username, password)
	VALUES('$name', '$email', '$username', '$password')");

echo "You have successfully Registered";

// mail user their information

$yoursite = ‘www.antipants.com’;
$webmaster = ‘Thomas Wolfe’;
$youremail = ‘tom.wolfe@gmail.com’;

$subject = "You have successfully registered at $yoursite...";
$message = "Dear $name, you are now registered with our web site.  
	To login, simply go to our web page and enter in the following details in the login form:
	Username: $username
	Password: $password
	
	Please print this information out and store it for future reference.
	
	Thanks,
	$webmaster";

mail($email, $subject, $message, "From: $yoursite <$youremail>\nX-Mailer:PHP/" . phpversion());

echo "Your information has been mailed to your email address.";
?>
